using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class TestInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Name,
			Description,
			Begin_Time,
			End_Time,
			Duration_Time,
			Ip_range,
			Results_To_User,
			Score_Right,
			Score_Wrong,
			Max_Score,
			Pass_Score,
			Random_Question_S,
			Random_Answers_S,
			Random_Question_O,
			Random_Answers_O,
			Logout_On_Timeout,
			Type,
			Enabled,
			ANAL_T9,
			ANAL_T8,
			ANAL_T7,
			ANAL_T6,
			ANAL_T5,
			ANAL_T4,
			ANAL_T3,
			ANAL_T2,
			ANAL_T1,
			ANAL_T0
		}
		private Int64 _ID;
		private String _Name;
		private String _Description;
		private Int32 _Begin_Time;
		private Int32 _End_Time;
		private Int32 _Duration_Time;
		private String _Ip_range;
		private Boolean _Results_To_User;
		private Decimal _Score_Right;
		private Decimal _Score_Wrong;
		private Decimal _Max_Score;
		private Decimal _Pass_Score;
		private Boolean _Random_Question_S;
		private Boolean _Random_Answers_S;
		private Boolean _Random_Question_O;
		private Boolean _Random_Answers_O;
		private Int32 _Logout_On_Timeout;
		private String _Type;
		private Boolean _Enabled;
		private String _ANAL_T9;
		private String _ANAL_T8;
		private String _ANAL_T7;
		private String _ANAL_T6;
		private String _ANAL_T5;
		private String _ANAL_T4;
		private String _ANAL_T3;
		private String _ANAL_T2;
		private String _ANAL_T1;
		private String _ANAL_T0;
		
		public Int64 ID{	get{ return _ID;} set{_ID = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String Description{	get{ return _Description;} set{_Description = value;} }
		public Int32 Begin_Time{	get{ return _Begin_Time;} set{_Begin_Time = value;} }
		public Int32 End_Time{	get{ return _End_Time;} set{_End_Time = value;} }
		public Int32 Duration_Time{	get{ return _Duration_Time;} set{_Duration_Time = value;} }
		public String Ip_range{	get{ return _Ip_range;} set{_Ip_range = value;} }
		public Boolean Results_To_User{	get{ return _Results_To_User;} set{_Results_To_User = value;} }
		public Decimal Score_Right{	get{ return _Score_Right;} set{_Score_Right = value;} }
		public Decimal Score_Wrong{	get{ return _Score_Wrong;} set{_Score_Wrong = value;} }
		public Decimal Max_Score{	get{ return _Max_Score;} set{_Max_Score = value;} }
		public Decimal Pass_Score{	get{ return _Pass_Score;} set{_Pass_Score = value;} }
		public Boolean Random_Question_S{	get{ return _Random_Question_S;} set{_Random_Question_S = value;} }
		public Boolean Random_Answers_S{	get{ return _Random_Answers_S;} set{_Random_Answers_S = value;} }
		public Boolean Random_Question_O{	get{ return _Random_Question_O;} set{_Random_Question_O = value;} }
		public Boolean Random_Answers_O{	get{ return _Random_Answers_O;} set{_Random_Answers_O = value;} }
		public Int32 Logout_On_Timeout{	get{ return _Logout_On_Timeout;} set{_Logout_On_Timeout = value;} }
		public String Type{	get{ return _Type;} set{_Type = value;} }
		public Boolean Enabled{	get{ return _Enabled;} set{_Enabled = value;} }
		public String ANAL_T9{	get{ return _ANAL_T9;} set{_ANAL_T9 = value;} }
		public String ANAL_T8{	get{ return _ANAL_T8;} set{_ANAL_T8 = value;} }
		public String ANAL_T7{	get{ return _ANAL_T7;} set{_ANAL_T7 = value;} }
		public String ANAL_T6{	get{ return _ANAL_T6;} set{_ANAL_T6 = value;} }
		public String ANAL_T5{	get{ return _ANAL_T5;} set{_ANAL_T5 = value;} }
		public String ANAL_T4{	get{ return _ANAL_T4;} set{_ANAL_T4 = value;} }
		public String ANAL_T3{	get{ return _ANAL_T3;} set{_ANAL_T3 = value;} }
		public String ANAL_T2{	get{ return _ANAL_T2;} set{_ANAL_T2 = value;} }
		public String ANAL_T1{	get{ return _ANAL_T1;} set{_ANAL_T1 = value;} }
		public String ANAL_T0{	get{ return _ANAL_T0;} set{_ANAL_T0 = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public TestInfo()
		{
			_ID = 0;
			_Name = "";
			_Description = "";
			_Begin_Time = 0;
			_End_Time = 0;
			_Duration_Time = 0;
			_Ip_range = "";
			_Results_To_User = true;
			_Score_Right = 0;
			_Score_Wrong = 0;
			_Max_Score = 0;
			_Pass_Score = 0;
			_Random_Question_S = true;
			_Random_Answers_S = true;
			_Random_Question_O = true;
			_Random_Answers_O = true;
			_Logout_On_Timeout = 0;
			_Type = "";
			_Enabled = true;
			_ANAL_T9 = "";
			_ANAL_T8 = "";
			_ANAL_T7 = "";
			_ANAL_T6 = "";
			_ANAL_T5 = "";
			_ANAL_T4 = "";
			_ANAL_T3 = "";
			_ANAL_T2 = "";
			_ANAL_T1 = "";
			_ANAL_T0 = "";
		}
		public TestInfo(
		Int64 ID,
		String Name,
		String Description,
		Int32 Begin_Time,
		Int32 End_Time,
		Int32 Duration_Time,
		String Ip_range,
		Boolean Results_To_User,
		Decimal Score_Right,
		Decimal Score_Wrong,
		Decimal Max_Score,
		Decimal Pass_Score,
		Boolean Random_Question_S,
		Boolean Random_Answers_S,
		Boolean Random_Question_O,
		Boolean Random_Answers_O,
		Int32 Logout_On_Timeout,
		String Type,
		Boolean Enabled,
		String ANAL_T9,
		String ANAL_T8,
		String ANAL_T7,
		String ANAL_T6,
		String ANAL_T5,
		String ANAL_T4,
		String ANAL_T3,
		String ANAL_T2,
		String ANAL_T1,
		String ANAL_T0
		)
		{
			_ID = ID;
			_Name = Name;
			_Description = Description;
			_Begin_Time = Begin_Time;
			_End_Time = End_Time;
			_Duration_Time = Duration_Time;
			_Ip_range = Ip_range;
			_Results_To_User = Results_To_User;
			_Score_Right = Score_Right;
			_Score_Wrong = Score_Wrong;
			_Max_Score = Max_Score;
			_Pass_Score = Pass_Score;
			_Random_Question_S = Random_Question_S;
			_Random_Answers_S = Random_Answers_S;
			_Random_Question_O = Random_Question_O;
			_Random_Answers_O = Random_Answers_O;
			_Logout_On_Timeout = Logout_On_Timeout;
			_Type = Type;
			_Enabled = Enabled;
			_ANAL_T9 = ANAL_T9;
			_ANAL_T8 = ANAL_T8;
			_ANAL_T7 = ANAL_T7;
			_ANAL_T6 = ANAL_T6;
			_ANAL_T5 = ANAL_T5;
			_ANAL_T4 = ANAL_T4;
			_ANAL_T3 = ANAL_T3;
			_ANAL_T2 = ANAL_T2;
			_ANAL_T1 = ANAL_T1;
			_ANAL_T0 = ANAL_T0;
		}
		public TestInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.ID.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
				_Begin_Time = dr[Field.Begin_Time.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Begin_Time.ToString()]);
				_End_Time = dr[Field.End_Time.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.End_Time.ToString()]);
				_Duration_Time = dr[Field.Duration_Time.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Duration_Time.ToString()]);
				_Ip_range = dr[Field.Ip_range.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ip_range.ToString()]);
				_Results_To_User = dr[Field.Results_To_User.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.Results_To_User.ToString()]);
				_Score_Right = dr[Field.Score_Right.ToString()] == DBNull.Value?0:Convert.ToDecimal(dr[Field.Score_Right.ToString()]);
				_Score_Wrong = dr[Field.Score_Wrong.ToString()] == DBNull.Value?0:Convert.ToDecimal(dr[Field.Score_Wrong.ToString()]);
				_Max_Score = dr[Field.Max_Score.ToString()] == DBNull.Value?0:Convert.ToDecimal(dr[Field.Max_Score.ToString()]);
				_Pass_Score = dr[Field.Pass_Score.ToString()] == DBNull.Value?0:Convert.ToDecimal(dr[Field.Pass_Score.ToString()]);
				_Random_Question_S = dr[Field.Random_Question_S.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.Random_Question_S.ToString()]);
				_Random_Answers_S = dr[Field.Random_Answers_S.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.Random_Answers_S.ToString()]);
				_Random_Question_O = dr[Field.Random_Question_O.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.Random_Question_O.ToString()]);
				_Random_Answers_O = dr[Field.Random_Answers_O.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.Random_Answers_O.ToString()]);
				_Logout_On_Timeout = dr[Field.Logout_On_Timeout.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Logout_On_Timeout.ToString()]);
				_Type = dr[Field.Type.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Type.ToString()]);
				_Enabled = dr[Field.Enabled.ToString()] == DBNull.Value?true:Convert.ToBoolean(dr[Field.Enabled.ToString()]);
				_ANAL_T9 = dr[Field.ANAL_T9.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T9.ToString()]);
				_ANAL_T8 = dr[Field.ANAL_T8.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T8.ToString()]);
				_ANAL_T7 = dr[Field.ANAL_T7.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T7.ToString()]);
				_ANAL_T6 = dr[Field.ANAL_T6.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T6.ToString()]);
				_ANAL_T5 = dr[Field.ANAL_T5.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T5.ToString()]);
				_ANAL_T4 = dr[Field.ANAL_T4.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T4.ToString()]);
				_ANAL_T3 = dr[Field.ANAL_T3.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T3.ToString()]);
				_ANAL_T2 = dr[Field.ANAL_T2.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T2.ToString()]);
				_ANAL_T1 = dr[Field.ANAL_T1.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T1.ToString()]);
				_ANAL_T0 = dr[Field.ANAL_T0.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ANAL_T0.ToString()]);
			}
		}
		public TestInfo(TestInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Name = objEntr.Name;			
			_Description = objEntr.Description;			
			_Begin_Time = objEntr.Begin_Time;			
			_End_Time = objEntr.End_Time;			
			_Duration_Time = objEntr.Duration_Time;			
			_Ip_range = objEntr.Ip_range;			
			_Results_To_User = objEntr.Results_To_User;			
			_Score_Right = objEntr.Score_Right;			
			_Score_Wrong = objEntr.Score_Wrong;			
			_Max_Score = objEntr.Max_Score;			
			_Pass_Score = objEntr.Pass_Score;			
			_Random_Question_S = objEntr.Random_Question_S;			
			_Random_Answers_S = objEntr.Random_Answers_S;			
			_Random_Question_O = objEntr.Random_Question_O;			
			_Random_Answers_O = objEntr.Random_Answers_O;			
			_Logout_On_Timeout = objEntr.Logout_On_Timeout;			
			_Type = objEntr.Type;			
			_Enabled = objEntr.Enabled;			
			_ANAL_T9 = objEntr.ANAL_T9;			
			_ANAL_T8 = objEntr.ANAL_T8;			
			_ANAL_T7 = objEntr.ANAL_T7;			
			_ANAL_T6 = objEntr.ANAL_T6;			
			_ANAL_T5 = objEntr.ANAL_T5;			
			_ANAL_T4 = objEntr.ANAL_T4;			
			_ANAL_T3 = objEntr.ANAL_T3;			
			_ANAL_T2 = objEntr.ANAL_T2;			
			_ANAL_T1 = objEntr.ANAL_T1;			
			_ANAL_T0 = objEntr.ANAL_T0;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Test");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int64)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.Description.ToString(), typeof(String)),
				new DataColumn(Field.Begin_Time.ToString(), typeof(Int32)),
				new DataColumn(Field.End_Time.ToString(), typeof(Int32)),
				new DataColumn(Field.Duration_Time.ToString(), typeof(Int32)),
				new DataColumn(Field.Ip_range.ToString(), typeof(String)),
				new DataColumn(Field.Results_To_User.ToString(), typeof(Boolean)),
				new DataColumn(Field.Score_Right.ToString(), typeof(Decimal)),
				new DataColumn(Field.Score_Wrong.ToString(), typeof(Decimal)),
				new DataColumn(Field.Max_Score.ToString(), typeof(Decimal)),
				new DataColumn(Field.Pass_Score.ToString(), typeof(Decimal)),
				new DataColumn(Field.Random_Question_S.ToString(), typeof(Boolean)),
				new DataColumn(Field.Random_Answers_S.ToString(), typeof(Boolean)),
				new DataColumn(Field.Random_Question_O.ToString(), typeof(Boolean)),
				new DataColumn(Field.Random_Answers_O.ToString(), typeof(Boolean)),
				new DataColumn(Field.Logout_On_Timeout.ToString(), typeof(Int32)),
				new DataColumn(Field.Type.ToString(), typeof(String)),
				new DataColumn(Field.Enabled.ToString(), typeof(Boolean)),
				new DataColumn(Field.ANAL_T9.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T8.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T7.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T6.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T5.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T4.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T3.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T2.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T1.ToString(), typeof(String)),
				new DataColumn(Field.ANAL_T0.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Name.ToString()] = _Name;
			row[Field.Description.ToString()] = _Description;
			row[Field.Begin_Time.ToString()] = _Begin_Time;
			row[Field.End_Time.ToString()] = _End_Time;
			row[Field.Duration_Time.ToString()] = _Duration_Time;
			row[Field.Ip_range.ToString()] = _Ip_range;
			row[Field.Results_To_User.ToString()] = _Results_To_User;
			row[Field.Score_Right.ToString()] = _Score_Right;
			row[Field.Score_Wrong.ToString()] = _Score_Wrong;
			row[Field.Max_Score.ToString()] = _Max_Score;
			row[Field.Pass_Score.ToString()] = _Pass_Score;
			row[Field.Random_Question_S.ToString()] = _Random_Question_S;
			row[Field.Random_Answers_S.ToString()] = _Random_Answers_S;
			row[Field.Random_Question_O.ToString()] = _Random_Question_O;
			row[Field.Random_Answers_O.ToString()] = _Random_Answers_O;
			row[Field.Logout_On_Timeout.ToString()] = _Logout_On_Timeout;
			row[Field.Type.ToString()] = _Type;
			row[Field.Enabled.ToString()] = _Enabled;
			row[Field.ANAL_T9.ToString()] = _ANAL_T9;
			row[Field.ANAL_T8.ToString()] = _ANAL_T8;
			row[Field.ANAL_T7.ToString()] = _ANAL_T7;
			row[Field.ANAL_T6.ToString()] = _ANAL_T6;
			row[Field.ANAL_T5.ToString()] = _ANAL_T5;
			row[Field.ANAL_T4.ToString()] = _ANAL_T4;
			row[Field.ANAL_T3.ToString()] = _ANAL_T3;
			row[Field.ANAL_T2.ToString()] = _ANAL_T2;
			row[Field.ANAL_T1.ToString()] = _ANAL_T1;
			row[Field.ANAL_T0.ToString()] = _ANAL_T0;
			return row;
		}
        #endregion InitTable
    }
}
